package com.xh.demo.mq.stream;

import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.DateUtil;
import com.xh.demo.mq.stream.source.DelayMessageInputSource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @author wen
 * @apiNote 消息通知MQ消费者
 * @since 2021-06-01
 */
@Slf4j
@Component
@EnableBinding({DelayMessageInputSource.class})
public class DelayNoticeConsumer {

    @StreamListener(DelayMessageInputSource.IN_PUT)
    public void handleDelay(String message) {
        log.info("【消息服务-STREAM-MQ异步消息通知-接收消息】【{}】【{}】", DateUtil.format(LocalDateTime.now(), DatePattern.NORM_DATETIME_PATTERN), message);
        // TODO do something
    }

}
